package kr.or.javacafe;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CalendarGridAdapter extends BaseAdapter{
	Context maincon;
	LayoutInflater Inflater;
	ArrayList<CalendarData> arSrc;
	int layout;
	int downPoint, upPoint;
		
	public CalendarGridAdapter(Context context, int alayout, ArrayList<CalendarData> aarSrc) {
		maincon = context;
		Inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		arSrc = aarSrc;
		layout = alayout;
	}

	@Override
	public int getCount() {
		return arSrc.size();
	}

	@Override
	public Object getItem(int position) {
		return arSrc.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = Inflater.inflate(layout, parent, false);
		}
				
		TextView Textday = (TextView)convertView.findViewById(R.id.GridDay);
		Textday.setText(arSrc.get(position).getDay()+"");
		
		if(arSrc.get(position).getWeek() == 7 || arSrc.get(position).getWeek() == -2)
			Textday.setTextColor(Color.BLUE);
		else if(arSrc.get(position).getWeek() == 1 || arSrc.get(position).getWeek() == -1)
			Textday.setTextColor(Color.RED);
		else
			Textday.setTextColor(Color.BLACK);
		
		return convertView;
	}

}
